package cn.bs.busuo.account.controller;


import cn.bs.busuo.account.pojo.param.City;
import cn.bs.busuo.account.pojo.param.Seasons;
import cn.bs.busuo.account.pojo.param.SightAdd;
import cn.bs.busuo.account.pojo.vo.SightListVO;
import cn.bs.busuo.account.pojo.vo.SightVO;
import cn.bs.busuo.account.service.ISightService;
import cn.bs.busuo.common.pojo.vo.PageData;
import cn.bs.busuo.common.web.JsonResult;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api(tags = "1.景点")
@RequestMapping("/sight/")
public class SightController {
    @Autowired
    private ISightService sightService;

    @ApiOperationSupport(order = 100)
    @ApiOperation("新增景点")
    @PostMapping("/insert")
    public JsonResult insert(SightAdd sightAdd, Seasons seasons, City city) {
        sightService.addSight(sightAdd, seasons,city);
        return JsonResult.ok();
    }

    @ApiOperationSupport(order = 200)
    @ApiOperation("删除景点")
    @PostMapping("/delect")
    public JsonResult delect(Long id) {
        sightService.delectSight(id);
        return JsonResult.ok();
    }

    @ApiOperationSupport(order = 250)
    @ApiOperation("查询景点列表")
    @GetMapping("/selectList")
    public JsonResult selectList(Integer pageNum, Integer pageSize) {
        PageData<SightListVO> sightListVOS = sightService.selectList(pageNum, pageSize);
        return JsonResult.ok(sightListVOS);
    }

    @ApiOperationSupport(order = 300)
    @ApiOperation("根据名字查询景点")
    @GetMapping("/select")
    public JsonResult select(String name) {
        SightVO sightById = sightService.getSightByName(name);
        return JsonResult.ok(sightById);
    }

    @ApiOperationSupport(order = 400)
    @ApiOperation("根据季节查询景点列表")
    @GetMapping("/selcteSeason")
    public JsonResult selcteSeason(Long seasonId) {
        List<SightListVO> sightListVOS = sightService.selcteSeason(seasonId);
        return JsonResult.ok(sightListVOS);
    }
    @ApiOperationSupport(order = 500)
    @ApiOperation("根据城市查询景点列表")
    @GetMapping("/selcteCity")
    public JsonResult selcteCity(Long id) {
        List<SightListVO> sightListVOS = sightService.selectList(id);
        return JsonResult.ok(sightListVOS);
    }

}
